<template>
	<view class="content">
		<view class="head">
			<view class="line">
				<view class="left">
					<view class="title">可提现余额</view>
					<view class="money">
						<view class="y">￥</view>
						<view class="num">{{info.balance?info.balance:0}}</view>
					</view>
				</view>
				<view class="right">
					<view class="btn" @click="isShowPopup = true">
						<image src="http://sni1muz85.hd-bkt.clouddn.com/img/icons/money1.png"></image>
						<text>提现</text>
					</view>
					<view class="text">(服务费 {{commission.percent}}%)</view>
				</view>
			</view>
		</view>

		<view class="box">
			<view class="title">余额明细</view>
			<view class="list">
				<view class="item" v-for="(item, index) in dataList" :key="index">
					<view class="left">
						<view class="type">{{ item.remark }}</view>
						<view class="time">{{ item.createTime }}</view>
					</view>
					<view style="display: flex;">
						<view class="right" v-show="item.type===0&& item.status===0">待审核</view>
						<view  class="right" v-show="item.type===0&& item.status===1">已审核</view>
						<view style="margin-left: 10rpx;" class="right" v-show="item.type===0&& item.status===1&&item.isPay === 0">未付款</view>

						<view  style="margin-left: 10rpx;" class="right" v-show="item.type===0&& item.status===1&&item.isPay === 1">已付款</view>
            <view  style="margin-left: 10rpx;" class="right" v-show="item.type===0&& item.status===1&&item.isPay === 2">付款中</view>
            <view  style="margin-left: 10rpx;" class="right" v-show="item.type===0&& item.status===1&&item.isPay === 3">付款中</view>

						<view v-show="item.type===0&& item.status===2">拒绝</view>
					</view>

					<view class="right" v-if="item.addOrCut === 1" :style="item.addOrCut === 1?'color: #07C160' : 'color: #FF734B'">- {{ item.money }}
					</view>
          <view class="right" v-if="item.addOrCut === 0" :style="item.addOrCut === 0?'color: #FF734B' : 'color: #07C160'">+ {{ item.money }}
          </view>

				</view>
			</view>
		</view>

		<view class="popup" v-if="isShowPopup">
			<view class="M"></view>
			<view class="box">
				<view class="title">提现</view>
				<view class="line">
					<view class="label">提现金额</view>
					<view class="money">
						<view class="">可提现金额：</view>
						<view class="num">{{info.balance}}</view>
					</view>
				</view>
				<view class="input-box">
					<input v-model="withDrawMoney" placeholder="¥" placeholder-style="font-weight: lighter" type="number">
				</view>
				<view class="tips">
					单笔可提现0.3—1000元
				</view>
				<view class="btnrow">
					<view class="btn btn1" @click="isShowPopup = false">取消</view>
					<view class="btn btn2" @click="withdraw">确认</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			dataList: [
				{
					type: 1,
					text: "提现成功",
					time: "2020-12-12 12:00:00",
					money: "- 200.00"
				},
				{
					type: 2,
					text: "签到卡已完成收入",
					time: "2020-12-12 12:00:00",
					money: "+ 200.00"
				},
			],
      info:{},
      commission:0,
			isShowPopup: false,
      withDrawMoney:null
		}
	},
  onLoad() {
    // 获取屏幕导航栏高度
    let value = uni.getStorageSync('navHeight')
    this.navHeight = value.height
    this.initData()
  },
	methods: {
    initData(){
      this.isShowPopup=false
      this.$api.request({
            url:this.$api.walletLog,
          }
      ).then(res=>{
        console.log(res)
        this.dataList=res.data
      })

      this.$api.request({
            url:this.$api.getInfo,
          }
      ).then(res=>{
        console.log(res)
        this.info=res.data
      })

      this.$api.request({
            url:this.$api.withdrawCommission,
            data:{"name":"finance"}
          }
      ).then(res=>{
        console.log(res)
        if (res.data){
          this.commission=JSON.parse(res.data[0].value)
        }

      })

    },
    withdraw(){
      let that=this;
      if (this.info.balance<this.withDrawMoney||this.withDrawMoney<=0){
        uni.showToast({
          title: '金额错误',
          duration: 2000,
          icon:"error"
        });
        console.log("456")
        return
      }
      this.$api.request({
            url:this.$api.withdraw,
            data:{"money":this.withDrawMoney}
          }
      ).then(res=>{
        that.initData();

      })
    },


	}
}
</script>

<style lang="less" scoped>
.content {
	display: flex;
	flex-direction: column;
	align-items: center;

	.head {
		width: 710rpx;
		height: 200rpx;
		border-radius: 15rpx;
		background: linear-gradient(to right, #FF4848, #FFB951);
		color: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 20rpx;


		.line {
			width: 710rpx;
			display: flex;
			justify-content: space-around;
			align-items: flex-start;

			.left {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				.title {
					font-size: 28rpx;
				}

				.money {
					display: flex;
					align-items: flex-end;
					// margin-top: 26rpx;

					.y {
						font-size: 32rpx;
						margin-bottom: 5rpx;
					}

					.num {
						font-size: 48rpx;
					}
				}
			}

			.right {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.btn {
					width: 200rpx;
					border-radius: 30rpx;
					background-color: #fff;
					display: flex;
					justify-content: center;
					align-items: center;
					padding: 10rpx 0;

					image {
						height: 32rpx;
						width: 32rpx;
					}

					text {
						font-size: 28rpx;
						color: #FF4C00;
						margin-left: 10rpx;
					}
				}

				.text {
					font-size: 22rpx;
					margin-top: 10rpx;
				}
			}
		}
	}

	.box {
		width: 710rpx;

		.title {
			font-size: 32rpx;
			// font-weight: bold;
			margin-top: 20rpx;
			color: #1A1A1A;
		}

		.list {
			margin-top: 20rpx;

			.item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-radius: 15rpx;
				padding: 30rpx 40rpx;
				margin-top: 20rpx;
				background-color: #fff;

				.left {
					.type {
						font-size: 28rpx;
						// font-weight: bold;
						color: #1A1A1A;
					}

					.time {
						font-size: 28rpx;
						color: #8A8A8A;
						margin-top: 10rpx;
					}
				}

				.right {
					font-size: 32rpx;
					columns: #333333;
				}
			}
		}
	}

	.popup {
		height: 100%;
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 10;

		.M {
			height: 100%;
			width: 100%;
			background-color: #000;
			opacity: 0.4;
		}

		.box {
			width: 80vw;
			position: absolute;
			top: 20%;
			left: 10vw;
			background-color: #fff;
			display: flex;
			flex-direction: column;
			align-items: center;
			border-radius: 15rpx;

			.title {
				font-size: 42rpx;
				font-weight: bold;
				margin-top: 20rpx;
			}
			.tips {
				color: #D1D1D1;
				align-self: flex-start;
				padding: 20rpx 30rpx 0;
				font-size: 26rpx;
			}
			.line {
				width: 90%;
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 40rpx;

				.label {
					font-size: 38rpx;
				}

				.money {
					display: flex;
					font-size: 28rpx;

					.num {
						color: #07C160;
					}
				}
			}

			.input-box {
				width: 90%;
				margin-top: 20rpx;

				input {
					height: 80rpx;
					font-size: 48rpx;
					font-weight: bold;
					border-bottom: 1rpx solid #aaa;
					// text-align: center;
				}
			}

			.btnrow {
				width: 90%;
				display: flex;
				justify-content: space-around;
				margin: 50rpx 0;

				.btn {
					height: 80rpx;
					width: 200rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 32rpx;
					color: #fff;
					border-radius: 15rpx;
				}

				.btn1 {
					background-color: #D1D1D1;
				}

				.btn2 {
					background-color: #07C160;
				}
			}
		}
	}
}
</style>
